package cn.net.nit.track.util;


import java.util.Date;

import net.sf.json.JSONObject;
import cn.net.nit.track.entry.GPSEvent;

public class GPSTransferUtil {

	public static JSONObject transferToJson(GPSEvent event) {

		JSONObject json = new JSONObject();
		if (event == null) {
			return json;
		}

		json.put("id", event.getId());
		json.put("longitude", event.getLongitude());
		json.put("latitude", event.getLatitude());
		json.put("direction", event.getDirection());
		json.put("speed", event.getSpeed());
		json.put("mobileNum", event.getMobileNum());
		json.put("timestamp", DateFormatUtil.formatDate(new Date(event.getTimestamp().getTime())));
		return json;
	}
}
